<?php
    /**
     * Form for creating the listing
     *
     */
class forms_CreateForm extends Zend_Form
{
    public function __construct($options = null)
    {
        parent::__construct($options);
        $this->setName('listing-form');
        $title = new Zend_Form_Element_Text('title');
        $title->setLabel('Listing Title:')
                  ->setRequired(true)
                  ->addValidator('NotEmpty')
                  ->addValidator('StringLength', 55, 3);

        $description = new Zend_Form_Element_Textarea('description');
        $description->setLabel('Description:')
                 ->setRequired(true)
                 ->addValidator('NotEmpty');

        $startPrice = new Zend_Form_Element_Text('startPrice');
        $startPrice->setLabel('Start Price:')
                 ->setRequired(true)
                 ->addValidator('NotEmpty')
                 ->addValidator('Float');

        $duration = new Zend_Form_Element_Text('duration');
        $duration->setLabel('Duration:')
                 ->setRequired(true)
                 ->addValidator('NotEmpty')
                 ->addValidator('Int');

        $delivery = new Zend_Form_Element_Text('delivery');
        $delivery->setLabel('Delivery Cost:')
                 ->setRequired(true)
                 ->addValidator('NotEmpty')
                 ->addValidator('Float');


        $this->addElements(array($title, $description, $startPrice, $duration, $delivery
            ));

        $this->clearDecorators();

        $this->addDecorator('FormElements')
         ->addDecorator('HtmlTag', array('tag' => '<div>'))
         ->addDecorator('Form');

        $this->setElementDecorators(array(
            array('ViewHelper'),
            array('Errors'),
            array('Description'),
            array('Label', array('tag' => 'div', 'separator'=>' ')),
            array('HtmlTag', array('tag' => 'div', 'class'=>'field')),
        ));
    }
}